#!/bin/bash

#Usage:
#ls_nfsvers [server_addr]

versions=$(< /proc/fs/nfsd/versions)
if [ -n "$1" ]; then
	versions=$(ssh "$1" cat /proc/fs/nfsd/versions)
fi

[[ -z "$versions" ]] && {
	echo "[Warn] get nfs versions fail" >&2
	exit 2
}

utilsVer=$(mount.nfs -V | awk -F '[ )]+' '{print $4}')
if vercmp $utilsVer '>=' 1.3; then
	egrep -o "\+[.0-9]+" <<<"$versions" > >(sed -e "s/+//" -e "s/^4$/4.0/")
else
	egrep -o "\+[.0-9]+" <<<"$versions" > >(sed -e "s/+//")
fi
